﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MosWar
{
    public partial class jGrabZakoulkiSetup : Form
    {
        public jGrabZakoulkiSetup()
        {
            InitializeComponent();
            searchTypes.Clear();
            searchTypes.Add(new searchModeItem("Искать равных", "equal"));
            searchTypes.Add(new searchModeItem("Искать сильных", "strong"));
            searchTypes.Add(new searchModeItem("Искать слабых", "weak"));
            searchTypes.Add(new searchModeItem("Искать из списка врагов", "enemy"));
            searchTypes.Add(new searchModeItem("Искать из списка жертв", "victim"));
        }

        public class searchModeItem
        {
            public string text;
            public string value;

            public override string ToString() { return text; }

            public searchModeItem(string a_text, string a_val)
            {
                text = a_text;
                value = a_val;
            }
        }

        public List<searchModeItem> searchTypes = new List<searchModeItem>();

        private void jGrabZakoulkiSetup_Load(object sender, EventArgs e)
        {
            string lastText = tbSearchTypeIndex.Text;

            cbSearchType.DataSource = searchTypes;
            cbSearchType.DisplayMember = "text";
            tbSearchTypeIndex.Text = lastText;
            cbSearchType.SelectedItem = searchTypes[int.Parse(Properties.Settings.Default["findEnemyType"].ToString())];
            rbSearchLevel_CheckedChanged(null, new EventArgs());
            rbSearchУровень_CheckedChanged(null, new EventArgs());

            Console.WriteLine(" cbSearchType.SelectedItem=" + cbSearchType.SelectedItem + "rbSearchУровень.Checked=" + rbSearchУровень.Checked.ToString());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default["findEnemyType"] = searchTypes.IndexOf((searchModeItem)cbSearchType.SelectedItem).ToString();
            Properties.Settings.Default.Save();
        }

        private void btnClearLog_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default["edLogFightWindow"] = "";
        }

        private void rbSearchLevel_CheckedChanged(object sender, EventArgs e)
        {
            cbSearchType.Enabled = rbSearchLevel.Checked;
        }

        private void rbSearchУровень_CheckedChanged(object sender, EventArgs e)
        {
            bool b = rbSearchУровень.Checked;
            label2.Enabled = b;
            tbSearchLevelMin.Enabled = b;
            label3.Enabled = b;
            tbSearchLevelMax.Enabled = b;
        }

        private void rbSearchLevel_Click(object sender, EventArgs e)
        {
            rbSearchLevel.Checked = true;
        }

        private void rbSearchУровень_Click(object sender, EventArgs e)
        {
            rbSearchУровень.Checked = true;
        }
    }
}
